<%@ page language="java" import="java.util.*,java.sql.*" pageEncoding="UTF-8"%>
<%
Connection con=null;
try{
Class.forName("com.mysql.jdbc.Driver");
String url="jdbc:mysql://localhost:3306/test";
String min="root";
String pas="root";
con=DriverManager.getConnection(url, min, pas);
if(con!=null){out.println("库连接成功！");}
else{out.println("库连接失败！");}
}catch(ClassNotFoundException cnfe){cnfe.printStackTrace();}catch(SQLException se){se.printStackTrace();}

String zh=request.getParameter("zh");
String mm=request.getParameter("mm");

Statement sm=con.createStatement();
String sql="select * from users where username='"+zh+"' and password='"+mm+"'";

ResultSet rs=sm.executeQuery(sql);

if(rs.next()){out.print("OK");
session.setAttribute("mmz", mm);
session.setAttribute("zh", zh);
response.sendRedirect("dlcgJsp.jsp");
}else{
session.invalidate();
out.println("用户不存在，可以选择注册或返回重新登录！");
%><a href="yhgl_dl.html">返回</a>||<a href="yhgl_zc.html">注册</a>"<%
}

%>


